<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page import="javax.naming.Context"%> 
<%@ page import="javax.sql.DataSource"%> 
<%@ page import="javax.naming.InitialContext"%> 
<%@ page import="java.sql.*"%> 
<%@page import="dataconn.dataconn"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@include file="../JS/adminsession.jsp" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../css/background.css" rel="stylesheet" type="text/css" />
<link href="../css/dtree.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../JS/dtree.js"></script>
</head>
 
 <BODY id=css-zen-garden>
<DIV id=container>
<DIV id=intro>
<DIV id=quickSummary>
<P class=p2>欢迎，<%=session.getAttribute("RealName") %>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../JS/logout.jsp">退出</a>&nbsp;&nbsp;&nbsp;<a href="../EditUser.jsp">修改资料</a>&nbsp;&nbsp;&nbsp;<a href="../MyBug.jsp">返回前台</a></P>
</DIV>
<DIV id=editmodule>
<H3><SPAN>修改模块</SPAN></H3>
    <form name="modulename" method="post" action="module_edit.jsp">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_style">
  <tr bgcolor="#52514E">
    <td colspan="2" align="center">修改模块名</td>
    </tr>
    <tr bgcolor="#52514E">
    <td width="30%">所属项目</td>
    <td align="left">
    <%     request.setCharacterEncoding("utf-8");
    String ModuleID1=request.getParameter("ModuleID");
    dataconn con=new dataconn();
    String sql="select ProjectName from TestProject,TestModule where TestModule.ProjectID=TestProject.ProjectID and ModuleID="+ModuleID1;
    ResultSet rs=con.executeQuery(sql); 
    rs.next();
    String ProjectName=rs.getString("ProjectName");
     %>
       &nbsp;&nbsp;&nbsp;&nbsp;<%=ProjectName%>
        </td>
  </tr>
  <tr bgcolor="#52514E">
    <td width="30%">原模块名</td>
    <td align="left">
    <%
    String sql1="select ModuleName from TestModule where ModuleID="+ModuleID1;
    ResultSet rs1=con.executeQuery(sql1); 
    rs1.next();
    String Old_ModuleName=rs1.getString("ModuleName");
     %>
        <input type="hidden" name="ModuleID" value="<%=ModuleID1 %>"/>
        &nbsp;&nbsp;&nbsp;&nbsp;<%=Old_ModuleName%>
        </td>
  </tr>
  <tr bgcolor="#52514E">
    <td>新模块名</td>
    <td align="left">
      <input name="ModuleName" type="text" class="selectlist" />
</td>
  </tr>
  <tr bgcolor="#52514E">
    <td colspan="2">
        <input type="submit" name="button2" id="button2" value="保存" />
    </td>
    </tr>
</table></form>
<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
</DIV>
</DIV>
<DIV id=supportingText></DIV>
<DIV id=linkList>
<DIV id=linkList2>
<DIV id=lusers>
<H3 class=users></H3>
<UL>
  <LI><a href="GroupMaintain.jsp"><SPAN 
  class=accesskey>浏览/维护分组</apan></a> </li> 
  <LI><A href="AddGroup.jsp"><SPAN 
  class=accesskey>添加新的分组</SPAN></A> </LI> 
    <LI><A href="AddUser.jsp"><SPAN 
  class=accesskey>浏览/维护用户</SPAN></A> </LI> 
  </UL>
</DIV>
<DIV id=lprojects>
<H3 class=projects></H3>
<UL>
    <LI><A href="NewProject.jsp"><SPAN 
  class=accesskey>新建项目</SPAN></A> </LI> 
<script> 
function go(obj){ 
self.location=obj.options[obj.selectedIndex].value; 
return false; 
} 
</script> 
        <LI>
        <form  method="post" action="ManageProject.jsp">
          <select name="project" class="treelist"  onchange="go(this)" >
            <option selected="selected">维护项目</option>
   <%
   String sql2="select ProjectName,ProjectID from TestProject where IsDropped='0'";
   ResultSet rs2=con.executeQuery(sql2);

   while(rs2.next())
   {
      String ProjectID2=rs2.getString("ProjectID");
      String ProjectName2=rs2.getString("ProjectName");
   %>
            <option value="ManageProject.jsp?ProjectID=<%=ProjectID2%>"><%=ProjectName2%></option>
            <%} %>
 <%
    rs2.close();
 %>
          </select>
        </form>
      </LI>
     <li> <%
//读取数据库产生形如Tree[0]  = "1|0|Page 1|#";
// nodeId | parentNodeId | nodeName | nodeUrl
//根目录的parentNodeId为0
String jscode="";
int k=0;
String sql4="select ProjectID from TestModule where ModuleID="+ModuleID1;
ResultSet rs4 = con.executeQuery(sql4);
rs4.next();
String ProjectID3=rs4.getString("ProjectID");
String sql3="select ModuleID,ParentID,ModuleName from TestModule where ProjectID="+ProjectID3;
ResultSet rs3 = con.executeQuery(sql3);
if (!rs3.next()) 
out.print("对不起，暂时没有数据!");
else{
	do{
	String ModuleID=rs3.getString("ModuleID");
	String ParentID=rs3.getString("ParentID");
	String ModuleName=rs3.getString("ModuleName");
	String url="ManageModule.jsp?ModuleID="+ModuleID;
	//jscode=jscode+"Tree["+ k +"]  = '"+ id +"|"+ pid +"|"+ name +"|"+ url +"';";
	jscode=jscode+"d.add("+ ModuleID +","+ ParentID +",'"+ ModuleName +"','"+ url +"');";
	k=k+1;
	}while(rs3.next());
}
rs3.close();
    con.closeConn();
    con.closeStmt(); 
%>

  
<div class="dtree">

	<p><a href="javascript: d.openAll();">展开所有</a> | <a href="javascript: d.closeAll();">关闭所有</a></p>

	<script type="text/javascript">
		<!--

		d = new dTree('d');
		d.add(0,-1,'该项目的模块');//由于缺少数据库缺少pid=-1的记录这里手动添加一个。
		<%=jscode%>

		document.write(d);

		//-->
	</script>

</div></li>
</UL>
</DIV></DIV></DIV></DIV>
</BODY>
</html>